﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using System.ComponentModel;

namespace SLBIARVerify.ClassLib
{
    public class NameCuidType : INotifyPropertyChanged
    {
        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        protected void NotifyPropertyChanged(String propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
        #endregion

        string name;
        public string Name { get { return name; } set { name = value; NotifyPropertyChanged("Name"); } }

        string type;
        public string Type { get { return type; } set { type = value; NotifyPropertyChanged("Type"); } }

        string cuid;
        public string Cuid { get { return cuid; } set { cuid = value; NotifyPropertyChanged("Cuid"); } }

        string parentcuid;
        public string ParentCuid { get { return parentcuid; } set { parentcuid = value; NotifyPropertyChanged("ParentCuid"); } }

        public int TypeOrderFactor
        {
            get
            {
                switch (Type)
                {
                    case "Folder":
                        return 1;
                    case "CrystalReport":
                        return 2;
                    case "Webi":
                        return 3;
                    default:
                        return 9;
                }
            }
        }

        int alterIndicator;

        public int AlterIndicator
        {
            get { return alterIndicator; }
            set
            {
                alterIndicator = value; NotifyPropertyChanged("AlterIndicator"); 
            }
        }

        //List<NameCuidType> children = new List<NameCuidType>();

        //public List<NameCuidType> Children
        //{
        //    get { return children; }
        //    set { children = value; }
        //}
    }

    public class CuidComparer : IEqualityComparer<NameCuidType>
    {

        public bool Equals(NameCuidType x, NameCuidType y)
        {
            if (x.Cuid == y.Cuid)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public int GetHashCode(NameCuidType obj)
        {
            return obj.Cuid.GetHashCode();
        }
    }

    public class NameComparer : IEqualityComparer<NameCuidType>
    {

        public bool Equals(NameCuidType x, NameCuidType y)
        {
            if (x.Name == y.Name)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public int GetHashCode(NameCuidType obj)
        {
            return obj.Name.GetHashCode();
        }
    }

    public class NameParentCuidComparer : IEqualityComparer<NameCuidType>
    {

        public bool Equals(NameCuidType x, NameCuidType y)
        {
            if (x.Name == y.Name && x.ParentCuid == y.ParentCuid)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public int GetHashCode(NameCuidType obj)
        {
            return (obj.Name + obj.ParentCuid).GetHashCode();
        }
    }
}
